<template>
<view class="uni-padding-wrap uni-common-pb">
    <!-- <button @click="test">sdfs</button>
    <button @click="test1">sdfs</button> -->
    <view class="head-box">
        <view class="head-tit">欢迎您登录：{{name}}</view>
        <view class="img"><image :src="avatarUrl"></image></view>
    </view>
    <act-list :list="actList"></act-list>      
</view>   
</template>
<script>
import {formatObjDate,formatDate,get,post} from '@/utils/index';
import {getActList,getActDetails,getSignList,signUp} from '@/utils/api';
import actList from '../../../components/act-list.vue'
export default {
    components: {
        actList
    },
    data () {
        return {
            userData:{},
            actList:[],
            dfimg:'../../../static/shuijiao.jpg',
            avatarUrl:'',
            name:''
        }
    },
    onShow: function() {
        let user = uni.getStorageSync('userInfo')
        this.userData = user
        this.avatarUrl = user.avatarUrl
        this.name = user.name
        
    },
    onLoad:function(){
        this.getActList()
    },
    methods:{
        init(){
            
        },
        test(){
            uni.navigateTo({
                url: '/pages/login/login'
            });
        },
        test1(){
            console.log(uni.getStorageSync('userInfo'))
        },
        getActList(){
            var that = this;
            uni.showNavigationBarLoading();
            this.more  = true;
            get(getActList,{
                row:1
            }, true)
            .then((res)=>{
                // this.actList = res
                console.log(98,res)
                formatObjDate(res).then((data)=>{
                    this.actList = data
                })               
                uni.hideNavigationBarLoading();
            })
        },
        goAct(id){
            uni.navigateTo({
                url: '/pages/tabBar/act/actShow?id='+id
            });
        },
        // init(){
        //     uni.connectSocket({
        //         url: 'wss://wx.igiky.cn/wss'
        //     });

        //     uni.onSocketOpen(function (res) {
        //         console.log(3,res)
        //         this.socketOpen = true;
        //         uni.sendSocketMessage({
        //             data: 'sdfsdfdsf',
        //             success: function (res) {
        //                 console.log('发送成功',res);
        //             }
        //         });
        //     });
        // },
        // sendSocketMessage(msg) {
        //     if (socketOpen) {
        //         uni.sendSocketMessage({
        //             data: msg
        //         });
        //     } else {
        //         socketMsgQueue.push(msg);
        //     }
        // },
        
        // test(){
        //     let user  = uni.getStorageSync('userInfo')
        //     console.log(user)
        //     uni.showToast({
        //         title: user.openid,
        //         duration: 2000
        //     });
        // },
        go1(){
            console.log('go122')
            uni.switchTab({
                url: '/pages/tabBar/act/act'
            });
        },
        go2(){
            console.log('go122')
            uni.switchTab({
                url: '/pages/tabBar/bless/bless'
            });
        },
        goLogin(){
            uni.navigateTo({
                url: '/pages/login/login'
            });
        }
    }
}
</script>

<style lang="scss" scoped>
button {
		margin-top: 30upx;
		margin-bottom: 30upx;
}
</style>
